package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.UserAccessDetailDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.UserAccessDetail;
import com.bestv.search.common.service.UserAccessDetailManager;

import java.util.List;

public class UserAccessDetailManagerImpl implements UserAccessDetailManager {

    private UserAccessDetailDao userAccessDetailDao;

    @Override
    public void saveOrUpdateUserAccessDetailList(DataSourceKey key, List<UserAccessDetail> list) {
        if (list.size() > 0) {
            // removes records first by date.
            userAccessDetailDao.removeByDate(list.get(0).getDate());
            // save all records to DB
            userAccessDetailDao.saveObjectList(list);
        }
    }

    public UserAccessDetailDao getUserAccessDetailDao() {
        return userAccessDetailDao;
    }

    public void setUserAccessDetailDao(UserAccessDetailDao userAccessDetailDao) {
        this.userAccessDetailDao = userAccessDetailDao;
    }
}